from tortoise import fields
from base.base_models import BaseModel
from enum import Enum


class BrowserChoice(str, Enum):
    CHROME = "CHROME"
    FIREFOX = "FIREFOX"
    SAFARI = "SAFARI"
    EDGE = "EDGE"
    IE = "IE"
    UNKNOWN = "UNKNOWN"


class SystemChoice(str, Enum):
    WINDOWS = "WINDOWS"
    MAC = "MAC"
    LINUX = "LINUX"
    ANDROID = "ANDROID"
    IOS = "IOS"
    UNKNOWN = "UNKNOWN"


class Message(BaseModel):
    qq = fields.CharField(max_length=20, index=True, description="QQ号")
    nickname = fields.CharField(max_length=20, description="昵称")
    website = fields.CharField(max_length=100, null=True, description="个人网站")
    content = fields.TextField(description="留言内容")
    browser = fields.CharEnumField(
        BrowserChoice, default=BrowserChoice.UNKNOWN, description="浏览器"
    )
    system = fields.CharEnumField(
        SystemChoice, default=SystemChoice.UNKNOWN, description="操作系统"
    )
    ip = fields.CharField(max_length=39, null=True, description="IP地址")

    class Meta:
        table = "tb_messages"
